#include "precom.h"
#include "GoochShader.h"

GoochShader::GoochShader()
{
	m_lightNum = 1;
}

GoochShader::~GoochShader()
{
}

bool GoochShader::CgShaderInit(HWND a_hWnd, CGcontext a_cg_context, CGprofile a_cg_vertProfile, CGprofile a_cg_fragProfile)
{
	cg_vertProg = cgCreateProgramFromFile(a_cg_context, CG_SOURCE, "Res/gooch.cg",
					a_cg_vertProfile, "goochvert", 0);
	if( cg_vertProg == NULL ) {
		CGerror err = cgGetError();
		MessageBoxA(a_hWnd, cgGetErrorString(err), "Error GoochVertCG", MB_OK);
		return false;
	}
	cg_fragProg = cgCreateProgramFromFile(a_cg_context, CG_SOURCE, "Res/gooch.cg",
					a_cg_fragProfile, "goochfrag", 0);
	if( cg_fragProg == NULL ) {
		CGerror err = cgGetError();
		MessageBoxA(a_hWnd, cgGetErrorString(err), "Error GoochFragCG", MB_OK);
		return false;
	}
	
	cgGLLoadProgram(cg_vertProg);
	cgGLLoadProgram(cg_fragProg);
	
	cg_lightPos[0] = cgGetNamedParameter(cg_vertProg, "LightPos");
	cg_modelViewMatrix = cgGetNamedParameter(cg_vertProg, "ModelView");
	cg_modelViewProjMatrix = cgGetNamedParameter(cg_vertProg, "ModelViewProj");
	return true;
}


std::vector<boost::function<void(float)>> GoochShader::SignUpForFloatInfo()
{
	std::vector<boost::function<void(float)>> ret;
	ret.resize(ShaderExternalFloatDataNum, NULL);
	return ret;
}

std::vector<boost::function<void(const fmath::vector3&)>> GoochShader::SignUpForVecInfo()
{
	std::vector<boost::function<void(const fmath::vector3&)>> ret;
	ret.resize(ShaderExternalVecDataNum, NULL);
	return ret;
}